#include "xprime.h"
#include "xtest.h"
#include "xutil.h"
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <random>

using namespace std;

int main1()
{
    //    locale::global(locale(""));
    //    cout.imbue(locale(""));
    //    system("chcp 65001");

    //    system("chcp 936");
    //    system("20127 ");
    //    test_save_primes();
    cout << "Hello World!" << endl;

    //    test_run_times(10, []() { cout << nextRandom(100, 100) << endl; });
    //    test_run_times(10, []() { cout << nextRandom(199) << endl; });
    //    test_run_times(100, []() { cout << nextRandom(30) << endl; });

    //test_run_times(100, []() { cout << nextRandomPrime() << endl; });

    size_t p = x_next_random_prime();
    size_t q = x_next_random_prime();

    size_t n = p * q; //10^12

    size_t ouer = (p - 1) * (q - 1); //10^12

    //与ouer互质的数 ouer-1 就这么简单！！！这是由定理证明过的
    size_t public_key = ouer - 1;

    xp(public_key);

    xp(x_gcd(public_key, ouer));

    xp(-12 % 100);

    //大指数计算非常大，怎么办计算呢？
    size_t a = 1000000;

    cout << a * a << endl; //no overflow

    __int128 b = 10000000000000000;
    cout << "__int128 sizeof:" << sizeof(__int128) << endl;
    b *= b;
    //    int bl = b % 10;
    //    cout << "int128 10 length:" << bl << endl;
    for (int i = 0; i < 50; i++) {
        int r = b % 10;
        cout << r;
        if (r == 1) {
            cout << endl;
            cout << i << endl;
        }
        b /= 10;
    }
    cout << endl;

    cout << "300的指数10^2是很大的" << endl; //no overflow

    cout << x_gcd(5, 3) << endl;

    xp(x_gcd(3, 5));

    return 0;
}
